#pragma once

#include "scene.h"
#include "game.h"
#include "object.h"
#include <list>
#include <random>

class SceneMain : public Scene {
public:
    SceneMain();
    ~SceneMain();

    virtual void init() override;
    virtual void clean() override;

    virtual void handleEvent(SDL_Event event) override;
    virtual void update(float deltaTime) override;
    virtual void render() override;

    void keyboardControls(float deltaTime);
    void shootPlayer();
    void shootEnemy(Enemy& enemy);
    void updateProjectilesPlayer(float deltaTime);
    void updateProjectilesEnemy(float deltaTime);
    void renderProjectilesPlayer();
    void renderProjectilesEnemy();

    SDL_FPoint getDirection(Enemy& enemy);

    void spawnEnemy();      /// 产生敌人
    void updateEnemies(float deltaTime);
    void renderEnemies();


    void updatePlayer(float deltaTime);
    void updateExplosions(float); 
    void renderExplosions();

    void enemyExplosion(Enemy* enemy);


private:
    /// 子弹模板
    ProjectilePlayer projectileTemplate_;
    
    /// 子弹对象列表
    /// 使用指针是怕子弹太多栈溢出
    std::list<ProjectilePlayer* > projectiles_;

    /// 敌人模板
    Enemy enemyTemplate_;

    /// 敌人对象列表
    std::list<Enemy*> enemies_;

    /// 敌人子弹模板
    ProjectileEnemy projectileEnemyTemplate_;

    /// 敌人子弹对象列表
    std::list<ProjectileEnemy* > projectiles_enemy_;

    /// explosion template
    Explosion explosionTemplate_;

    /// explosion object list
    std::list<Explosion*> explosions_;

    /// 随机数生成器, 随机数分布
    std::mt19937 gen_;
    std::uniform_real_distribution<float> dis_;

    Player player_;
    Game& game_;
};